package algorithm.arithmetic.求最大公约数和最小公倍数;

/**
 * @author xinchen by 2016/11/28
 * @version 1.0
 */
public class Solution {
    // 输入两个正整数m和n，求其最大公约数和最小公倍数
    public static void main(String[] args) {
        // args = new String[]{"2", "4"};
        int num1 = Integer.parseInt(args[0]);
        int num2 = Integer.parseInt(args[1]);
        int maxYueshu = 1;
        int minYueshu;
        do {
            minYueshu = getMinYueshu(num1, num2);
            maxYueshu *= minYueshu;
            num1 = num1 / minYueshu;
            num2 = num2 / minYueshu;
        } while (minYueshu != 1);
        System.out.println(maxYueshu + " " + maxYueshu * num1 * num2);
    }

    private static int getMinYueshu(int num1, int num2) {
        for (int i = 2; i <= Math.min(num1, num2); i++) {
            if (num1 % i == 0 && num2 % i == 0) {
                return i;
            }
        }
        return 1;
    }
}
